<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2021/9/3
  Time: 20:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/common/common.jsp"%>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript">
        function buildPage(page){
            $("#pageNum").val(page.pageNum);
            $("#pages").val(page.pages);
            $("#total").val(page.total);
            $("#pageSize").val(page.pageSize);
            $("#delete").val(page.list.mid);
        }
        function toPage(flag){
            var pageNum = parseInt($("#pageNum").val());
            var pages = parseInt($("#pages").val());
            if (flag == 1){//上一页
                if (pageNum <= 1){
                    toastr.error("已经是首页");
                    toastr.success("已经是首页");
                    toastr.info("已经是首页");
                    toastr.warning("已经是首页");
                    return;
                }
                $("#pageNum").val(pageNum-1);
            }
            else if (flag == 2){//下一页
                if (pageNum >= pages){
                    toastr.error("已经是最后一页");
                    toastr.success("已经是最后一页");
                    toastr.info("已经是最后一页");
                    toastr.warning("已经是最后一页");
                    return;
                }
                $("#pageNum").val(pageNum+1);
            }else if(flag == 3){
                $("#pageNum").val(1);
            }else  if (flag == 4){
                $("#pageNum").val(pages);
            }
            news();
        }
        function deleteBatch(){
            var checkArr = document.getElementsByName("check");
            var array = "";
            for (var i = 0; i < checkArr.length; i++) {
                if (checkArr[i].checked){
                    array += "," +checkArr[i].value;
                }
            }
            var arr = array.substring(1).split(",");
            location.href="<%=path%>/news/deleteBath?array="+arr;
        }
    </script>
</head>
<body>
<a href="javascript:toPage(3)">首页</a>
<a href="javascript:toPage(1)">上一页</a>
<a href="javascript:toPage(2)">下一页</a>
<a href="javascript:toPage(4)">尾页</a>
第<input type="text" id="pageNum" name="pageNum" size="2px" readonly="readonly">页
共<input type="text" id="total"  name="total" size="2px" readonly="readonly">条
总<input type="text" id="pages"  name="pages" size="2px" readonly="readonly">页
每页<input type="text" id="pageSize"  name="pageSize" size="2px" readonly="readonly">条
</body>
</html>
